<template>
  <div>
  	<keep-alive>
	    <router-view v-if="$route.meta.keepAlive">
	        <!-- 这里是会被缓存的视图组件，比如 home！ -->
	    </router-view>
		</keep-alive>
		<router-view v-if="!$route.meta.keepAlive">
    	<!-- 这里是不被缓存的视图组件，比如 order！ -->
		</router-view>
  </div>
</template>

<script type="text/ecmascript-6">
  import { urlParse } from 'common/js/util';
  import header from 'components/header/header.vue';

  export default {
    data() {
      return {
        seller: {
        },
        code:"",
        mchtId:"",
        table:""
      };
    },
    created() {
    	//获取到code存到缓存中
//  	console.log(window.location.href);
    	if(!sessionStorage.getItem("code")){
    		this.code = this.getQueryString("code");
    		this.mchtId = this.getQueryString("mchtId");
    		this.table = this.getQueryString("table");
    		sessionStorage.setItem("code",this.code);
    		sessionStorage.setItem("mchtId",this.mchtId);
    		sessionStorage.setItem("table",this.table);
    	}else{
    		sessionStorage.removeItem("code");
    		sessionStorage.removeItem("mchtId");
    		sessionStorage.removeItem("table");
    		this.code = this.getQueryString("code");
    		this.mchtId = this.getQueryString("mchtId");
    		this.table = this.getQueryString("table");
    		sessionStorage.setItem("code",this.code);
    		sessionStorage.setItem("mchtId",this.mchtId);
    		sessionStorage.setItem("table",this.table);
    	};
//
//			console.log(this.code);
//			console.log(this.mchtId);
//			console.log(this.table);

    },
     methods:{
     	 getQueryString(name){
     	 	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		    var r = window.location.search.substr(1).match(reg);
		    if ( r != null ){
		       return unescape(r[2]);
		    }else{
		       return null;
		    }
     	 }
     },
    components: {
      'v-header': header
    }
  };

</script>

<style lang="stylus" rel="stylesheet/stylus">
  @import "./common/stylus/mixin.styl"
  .tab
    display: flex
    width: 100%
    height: 40px
    line-height: 40px
    background:#f2f2f2
  // border-bottom: 1px solid rgba(7, 17, 27, 0.1)
    border-1px(rgba(7, 17, 27, 0.1))
    .tab-item
      flex: 1
      text-align: center
      display: block
      height: 40px
      font-size: 14px
      color: rgb(77, 85, 93)
      box-sizing: border-box
      &.active
        color: #e6893c
        border-bottom:2px solid #e6893c
</style>
